from django.db import models

from utils.model import BaseModel


class SwimmingsInfo(models.Model):
    name = models.CharField(max_length=150, verbose_name="馆名")
    info = models.TextField(verbose_name='详情')
    capacity = models.IntegerField(verbose_name="容量", default=1000)
    state = models.BooleanField(default=True, verbose_name='是否开馆')

    class Meta:
        db_table = 'swimming_info'
        verbose_name_plural = '馆信息表'

    def __str__(self):
        return self.name


class Swimnum(models.Model):
    num = models.IntegerField(verbose_name="当前人数", default=0)
    total=models.IntegerField(verbose_name='今日总人数',default=0)
    class Meta:
        db_table = 'swim_num'
        verbose_name_plural = '馆内人数表'

    def __str__(self):
        return self.num


class SwimPeopleNum(models.Model):
    num = models.IntegerField(verbose_name="人数", default=0)
    date = models.DateField(auto_now=True, verbose_name="时间")

    class Meta:
        db_table = 'swimming_peopleNum'
        verbose_name_plural = '历史人数表'


class Banner(BaseModel):
    title = models.CharField(max_length=16, unique=True, verbose_name='名称')
    image = models.ImageField(upload_to='banner', verbose_name='图片')
    link = models.CharField(max_length=64, verbose_name='跳转链接')
    info = models.TextField(verbose_name='详情')

    class Meta:
        db_table = 'swimming_banner'
        verbose_name_plural = '轮播图表'

    def __str__(self):
        return self.title

